from django.conf.urls import url
from . import views
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

router = DefaultRouter()
router.register(r'addresses', views.AddressViewSet, base_name='addresses')

urlpatterns = [
    # 检查用户是否存在
    url(r'^usernames/(?P<username>\w{5,20})/count/$', views.UserNameCountView.as_view()),
    # 检查手机号是否存在
    url(r'^usernames/(?P<mobile>1[3-9]\d{9})/count/$', views.MobileCountView.as_view()),
    # 注册
    url(r'user/$', views.CreateUserView.as_view()),
    # 登录
    # url(r'^authorizations/$', obtain_jwt_token),
    # 重写登录的方法实现登录合并购物车信息
    url(r'^authorizations/$', views.UserAuthorizeView.as_view()),
    # 个人信息
    url(r'user/$', views.UserDetailView.as_view()),
    # 保存邮箱
    url(r'emails/$', views.EmailView.as_view()),
    # 激活邮箱链接
    url(r'emails/verification/$', views.VerifyEmailUrl.as_view()),
    url(r'browse_history/$', views.AddBrowserHistory.as_view()),
    # 用户的浏览的历史记录
    url(r'browse_histories/$', views.AddBrowserHistory.as_view()),
]

urlpatterns += router.urls
